class XueyuanGuanli:
    sutdent = {
        "张三": ["101", "张三", "男"]
    }

    # 操作
    def info_print(self):
        print("请输入功能")
        print("1、添加学员")
        print("2、删除学员")
        print("3、修改学员信息")
        print("4、查询学员信息")
        print("5、显示所有学员信息")
        print("6、退出系统")
        print("-" * 20)

    # 添加学员
    def insert_info(self, info, name, sex):
        ii = False
        for i in self.sutdent.items():
            if (info == i[1][0]) or (name == i[1][1]):
                ii = True
        if ii:
            self.sutdent[name] = [info, name, sex]
            print("添加成功")
        else:
            print("添加失败，学号或姓名已存在")

    # 删除学员
    def del_info(self, name):
        del self.sutdent[name]

    # 修改学员信息
    def modify_info(self, info, name, sex):
        if info != None:
            self.sutdent[name][0] = info
        elif name != None:
            self.sutdent[name][1] = sex
        elif sex != None:
            self.sutdent[name][2] = sex

    # 查找学员信息
    def serch_info(self, name):
        print(self.sutdent[name])

    # 查找所有学员信息
    def serchAll_info(self):
        for i in self.sutdent.items():
            print(f"学号：{i[1][0]}___姓名：{i[1][1]}___性别：{i[1][2]}")


if __name__ == '__main__':
    st = XueyuanGuanli()
    while True:
        st.info_print()
        sum = int(input("请输入功能序号："))
        try:
            if sum == 1:
                info = input("请输入学号")
                name = input("请输入姓名")
                sex = input("请输入性别")
                st.insert_info(info, name, sex)
            elif sum == 2:
                dl = input("请输入您要删除学员的姓名")
                st.del_info(dl)
            elif sum == 3:
                modify_name = input("您要修改学员信息的姓名：")
                modify = input("您要修改学员的什么：1、学号；2、姓名；3、性别")
                if modify == "1":
                    infoM = input("请输入学号：")
                    st.modify_info(info=infoM, name=modify_name, sex=None)
                elif modify == "2":
                    nameM = input("请输入姓名：")
                    st.modify_info(name=modify_name, sex=nameM, info=None)
                elif modify == "3":
                    sexM = input("请输入性别：")
                    st.modify_info(sex=sexM, name=modify_name, info=None)
            elif sum == 4:
                name = input("请输入查找学员的姓名：")
                st.serch_info(name)
            elif sum == 5:
                st.serchAll_info()
            elif sum == 6:
                print("已退出")
                break
        except:
            print("输入错误，重新操作")
